/**
 * Copyright (c) 2017-2017 All Rights Reserved.
 */
package com.zbest.zpay.exchange.biz.action.pay;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zbest.zpay.exchange.dal.dao.FluxInfoDAO;
import com.zbest.zpay.exchange.dal.model.FluxInfoDO;
import com.zbest.zpay.exchange.helper.SeqHelper;
import com.zbest.zpay.service.exchange.FinCardPayRequest;
import com.zbest.zpay.service.exchange.model.FluxInfoStatus;
import com.zbest.zpay.service.exchange.model.FluxKeyEnum;
import com.zbest.zpay.shared.process.BaseAction;
import com.zbest.zpay.shared.process.ProcessResult;

/**
 * 生成金融账户支付信息
 *
 * @author Administrator
 * @version $Id: GenFinAccountPayInfoAction.java, v 0.1 2017-4-16 上午11:01:18 Administrator Exp $
 */
@Service("genFinCardPayInfoAction")
public class GenFinCardPayInfoAction extends BaseAction {

    @Resource
    private FluxInfoDAO fluxInfoDAO;

    @Resource
    private SeqHelper   seqHelper;

    /** 
     * @see com.zbest.zpay.shared.process.BaseAction#perform(com.zbest.zpay.shared.process.ProcessResult)
     */
    @Override
    public void perform(ProcessResult processResponse) {

        FinCardPayRequest request = getValue(FluxKeyEnum.FIN_CARD_PAY_REQUEST.getCode());

        FluxInfoDO fluxInfoDO = new FluxInfoDO();
        fluxInfoDO.setFluxId(seqHelper.genFluxInfoId());
        fluxInfoDO.setInstSerialNo(seqHelper.genInstSerialNo(request.getChannelId()));
        fluxInfoDO.setAmount(request.getAmount());
        fluxInfoDO.setChannelId(request.getChannelId());
        fluxInfoDO.setCurrency(request.getCurrency());
        fluxInfoDO.setPaySubInfoId(request.getPaySubInfoId());
        fluxInfoDO.setStatus(FluxInfoStatus.INITIAL.getCode());
        fluxInfoDO.setUserId(request.getUserId());

        fluxInfoDAO.insert(fluxInfoDO);

        setValue(FluxKeyEnum.FLUX_INFO_DO.getCode(), fluxInfoDO);
    }

}
